package com.yanqu.road.server.manager.config;

import com.yanqu.road.entity.config.beauty.BeautyInfo;
import com.yanqu.road.entity.config.skill.SkillInfo;
import com.yanqu.road.entity.config.skill.SkillUpgradeInfo;
import com.yanqu.road.entity.enums.ePatronsSkillType;
import com.yanqu.road.entity.enums.eSkillType;
import com.yanqu.road.entity.player.ReturnData;
import com.yanqu.road.entity.player.UserBeauty;
import com.yanqu.road.entity.player.UserPatrons;
import com.yanqu.road.entity.player.UserPatronsSkill;
import com.yanqu.road.logic.bussiness.config.SkillBussiness;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.protocol.GameErrorCode;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 技能信息管理
 */
public class SkillMgr extends TempMgr {

    private static Map<Integer, SkillInfo> skillInfoMap;

    private static Map<Integer, Map<Integer, SkillUpgradeInfo>> skillUpgradeInfoMap;

    private static  Map<Integer, List<SkillInfo>> skillInfoTypeListMap;

    /**
     * 蛐蛐普通技能
     */
    private static List<SkillInfo> cricketNormalSkill = new ArrayList<>();

    public static int getSkillMaxLvByUpgradeType(int type) {
        int maxLv = 0;
        List<SkillUpgradeInfo> skillUpgradeInfoList = getSkillUpgradeInfoList(type);
        for (SkillUpgradeInfo info : skillUpgradeInfoList) {
            if (maxLv < info.getLevel()) {
                maxLv = info.getLevel();
            }
        }
        return maxLv;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    @Override
    public boolean save() {
        return false;
    }

    @Override
    public boolean reloadConfig() {
        skillInfoMap = SkillBussiness.getSkillInfoMap();
        skillUpgradeInfoMap = SkillBussiness.getSkillUpgradeInfoMap();
        loadSkillTypeConsumeMap();
        loadCricketSkill();
        return true;
    }

    public void loadSkillTypeConsumeMap() {
        Map<Integer, List<SkillInfo>> _skillInfoTypeList = new HashMap<>();
        skillInfoMap.forEach((k, v) -> {
            if (!_skillInfoTypeList.containsKey(v.getType())) {
                _skillInfoTypeList.put(v.getType(), new ArrayList<>());
            }
            _skillInfoTypeList.get(v.getType()).add(v);
        });
        skillInfoTypeListMap = _skillInfoTypeList;
    }


    public void loadCricketSkill() {


        for (SkillInfo skillInfo : skillInfoMap.values()) {
            if (skillInfo.getType() != eSkillType.CricketBattleSkill137.getValue()) {
                continue;
            }
            /**
             * upgradeParams2 技能标签
             * 0 无标签
             * 1 流血型
             * 2 减攻型
             *
             * 3 普通
             */
            if (skillInfo.getUpgradeParamList().get(1) == 3) {
                cricketNormalSkill.add(skillInfo);
            }
        }
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    public static SkillInfo getSkillInfo(int skillId){
        return skillInfoMap.get(skillId);
    }

    //获取指定升级类型的当前等级的升级消耗
    public static ReturnData getUpgradeConsume(int upgradeType, int curLv) {

        //下一等级的升级参数 获取用来判断 不存在则已经满级
        SkillUpgradeInfo nextSkillUpgradeInfo = SkillMgr.getSkillUpgradeInfo(upgradeType, curLv + 1);

        //当前等级的升级参数
        SkillUpgradeInfo skillUpgradeInfo = SkillMgr.getSkillUpgradeInfo(upgradeType, curLv);
        if (nextSkillUpgradeInfo == null || skillUpgradeInfo == null) {
            return new ReturnData(GameErrorCode.E_UPGRADE_LEVEL_MAX);
        }
        return new ReturnData(0, String.valueOf(skillUpgradeInfo.getConsumeCount()));
    }

    public static SkillUpgradeInfo getSkillUpgradeInfo(int upgradeType, int level) {
        if(skillUpgradeInfoMap.containsKey(upgradeType)){
            return skillUpgradeInfoMap.get(upgradeType).get(level);
        }
        return null;
    }

    public static List<SkillUpgradeInfo> getSkillUpgradeInfoList(int upgradeType) {
        List<SkillUpgradeInfo> skillUpgradeInfos = new ArrayList<>();
        if (skillUpgradeInfoMap.containsKey(upgradeType)) {
            skillUpgradeInfos = new ArrayList<>(skillUpgradeInfoMap.get(upgradeType).values());
        }
        if (skillUpgradeInfos.size() > 0) {
            skillUpgradeInfos.sort(Comparator.comparing(SkillUpgradeInfo::getLevel));
        }
        return skillUpgradeInfos;
    }

    //初始化钱庄信誉等级对应的技能
    public static Map<Integer, Map<Integer, Integer>> initHouseSkillAdditionMap(List<Integer> skillList){
        Map<Integer, Map<Integer, Integer>> additionMap = new ConcurrentHashMap<>();
        for(Integer skillId : skillList){
            SkillInfo skillInfo = getSkillInfo(skillId);
            if(null == skillInfo){
                continue;
            }
            if(!additionMap.containsKey(skillInfo.getType())){
                additionMap.put(skillInfo.getType(), new ConcurrentHashMap<>());
            }
            int param3 = skillInfo.getParamList().get(2);
            int addition = 0;
            if(additionMap.get(skillInfo.getType()).containsKey(param3)){
                addition = additionMap.get(skillInfo.getType()).get(param3);
            }
            //钱庄技能都是1级
            addition += getSkillAddition(skillInfo, 1);
            additionMap.get(skillInfo.getType()).put(param3, addition);
        }
        return additionMap;
    }

    public static Map<Integer, Map<Integer, Integer>> initIdentitySkillAdditionMap(Map<Integer, UserBeauty> beautyMap){
        Map<Integer, Map<Integer, Integer>> additionMap = new ConcurrentHashMap<>();
        for(UserBeauty userBeauty : beautyMap.values()){
            BeautyInfo beautyInfo = BeautyMgr.getBeautyInfo(userBeauty.getBeautyId());
            SkillInfo skillInfo = getSkillInfo(beautyInfo.getIdentitySkillId());
            if(null == skillInfo){
                continue;
            }
            if(!additionMap.containsKey(skillInfo.getType())){
                additionMap.put(skillInfo.getType(), new ConcurrentHashMap<>());
            }
            int param3 = skillInfo.getParamList().get(2);
            int addition = 0;
            if(additionMap.get(skillInfo.getType()).containsKey(param3)){
                addition = additionMap.get(skillInfo.getType()).get(param3);
            }
            addition += getSkillAddition(skillInfo, userBeauty.getIdentitySkillLv());
            additionMap.get(skillInfo.getType()).put(param3, addition);
        }
        return additionMap;
    }

    public static Map<Integer, Map<Integer, Integer>> initTalentSkillAdditionMap(Map<Integer, UserPatrons> patronsMap){
        Map<Integer, Map<Integer, Integer>> additionMap = new ConcurrentHashMap<>();
        for(UserPatrons userPatrons : patronsMap.values()){
            for(UserPatronsSkill patronsSkill : userPatrons.getSkillList()){
                if(patronsSkill.getType() != ePatronsSkillType.Talent.getValue()){
                    continue;
                }
                SkillInfo skillInfo = getSkillInfo(patronsSkill.getSkillId());
                if(null == skillInfo){
                    continue;
                }
                if(!additionMap.containsKey(skillInfo.getType())){
                    additionMap.put(skillInfo.getType(), new ConcurrentHashMap<>());
                }
                int param3 = skillInfo.getParamList().get(2);
                int addition = 0;
                if(additionMap.get(skillInfo.getType()).containsKey(param3)){
                    addition = additionMap.get(skillInfo.getType()).get(param3);
                }
                addition += getSkillAddition(skillInfo, patronsSkill.getSkillLv());
                additionMap.get(skillInfo.getType()).put(param3, addition);
            }
        }
        return additionMap;
    }

    public static int getSkillAdditionFromMap(int skillType, int param, Map<Integer, Map<Integer, Integer>> skillAdditionMap){
        Map<Integer, Integer> typeMap = skillAdditionMap.get(skillType);
        if(null == typeMap){
            return 0;
        }
        int addition = 0;
        if(typeMap.containsKey(0)){
            addition = typeMap.get(0);
        }
        if(param > 0 && typeMap.containsKey(param)){
            addition += typeMap.get(param);
        }
        return addition;
    }

    /**
     * 获取美名技能加成
     */
    public static int getIdentitySkillAddition(Map<Integer, UserBeauty> beautyMap, int skillType, int param){
        Map<Integer, Map<Integer, Integer>> skillAdditionMap = initIdentitySkillAdditionMap(beautyMap);
        return getSkillAdditionFromMap(skillType, param, skillAdditionMap);
    }

    /**
     * 获取天赋技能加成
     */
    public static int getTalentSkillAddition(Map<Integer, UserPatrons> patronsMap, int skillType, int param){
        Map<Integer, Map<Integer, Integer>> skillAdditionMap = initTalentSkillAdditionMap(patronsMap);
        return getSkillAdditionFromMap(skillType, param, skillAdditionMap);
    }

    public static int getSkillAddition(SkillInfo skillInfo, int skillLv){
        int addition = 0;
        if(0 >= skillLv){
            return addition;
        }
        if(eSkillType.Ability.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.Qualification.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.DispatchEarn.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BattleEffect.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.ChildEarnSpeed.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.MineOutput.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BeautyExp.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.StaffRecruitCost.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BeLike.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.PassBattleCost.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TradeWarScoreItem.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.VehicleLevel.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.VehicleStudyLv.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.TravelAddPrestige.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.BuildingLevel.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.PassBossBuyBuffCost.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.LonelyEarnSpeedAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.ChildTrainAddPatronsExp.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BeautyTrystAddBeautyExp.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.MineWarAddOutput.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TradeWarAddMyScore.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TradeWarEnemyLoseScore.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.HuntAddPatronsBattleTimes.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.SacrificeAddDamage.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TradeWarAddScore.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BeautyPatronsSkill1.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1) + (skillLv - 1)*(skillLv - 2)*skillInfo.getUpgradeParamList().get(2)/2);
        }else if(eSkillType.BeautyPatronsSkill2.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1) + (skillLv - 1)*(skillLv - 2)*skillInfo.getUpgradeParamList().get(2)/2);
        }else if(eSkillType.BeautyBanquetPopularitySkill.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.BanquetJoinPopularitySkill.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TravelPowerGiftLimitAdd.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.CommonActivityScoreAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.ChildEarnSpeedSexAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.ChildTrainAddPatronsExpSexAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if(eSkillType.TrainCasinoDiceWin.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.AddPatronsAbility.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.AddChildAbility.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinAddIntimacy.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinAddGlamour.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.AddPatronsAbilityByOccupation.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.HuaShiGangDamageAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.PatronsCookSkill.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1) + (skillLv - 1)*(skillLv - 2)/2*skillInfo.getUpgradeParamList().get(2));
        }else if (eSkillType.VehicleCombSkill.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.StrongholdAdditionSkill.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.StrongholdEliminateAdditionSkill.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.DafuwengAddPatronsDamage.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinAddAllIntimacy.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinAddAllGlamour.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ClinicDiseaseEarnSpeedAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.ShuiHuRecycleCardAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.HuaShiGangBossDamageAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.TradeWarLoseScoreReduce.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.GhostAttackAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.GhostTalentAttackAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.CrossUnionWarLianShengTimesAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.CrossUnionWarAbilityAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.HuaShiGangBattleDamageAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.SkinVolumePatronsQualificationAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinVolumeBeautyIntimacyAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinVolumeBeautyGlamourAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinVolumePatronsLvLimitAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ManorOutPutAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.ManorBuildingStaffEarnAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ManorBuildingEarnAddRatio.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.ManorPatronsAbilityAddValue.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ManorPatronsQualificationAddValue.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ManorBeautyGlamourAddValue.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ManorBuildingTypeEarnAddRatio.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.ManorBeautyIntimacyAddValue.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if(eSkillType.BeautyPatronsEscortSkill1.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1) + (skillLv - 1)*(skillLv - 2)*skillInfo.getUpgradeParamList().get(2)/2);
        }else if(eSkillType.BeautyPatronsEscortSkill2.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1) + (skillLv - 1)*(skillLv - 2)*skillInfo.getUpgradeParamList().get(2)/2);
        } else if (eSkillType.DunHuangShiKuBloodAddRatio.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.DunHuangShiKuAttackAddRatio.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.ZsSeatAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.BeautyEscortFreeTimesAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.CombPatronsEarnSpeedAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.CombPatronsQualificationAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ZsOpenAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SpecialOccupationPatronsAbilityAddRatio.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.WineShopOccupationBeautyIntimacyAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.WineShopOccupationBeautyGlamourAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.WineShopPatronsBaiYeExpAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.WineShopBeautyEscortExpAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SpecialPatronsQualificationAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.CALABASH_BROTHERS_QUEEN.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.CALABASH_BROTHERS_KING.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.FishPondStageSkillMaxLevelAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinBeautySkillAddPatronsAbility.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkinBeautySkillAddPatronsAbilityAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.SkinPatronsSkillAddPatronsQualification.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.PatronsNewCombSkill.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SeacraftPirateRiotAtkAddi.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.WingRoomComfortValueAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.SkillMaxLevelAdd.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.UnionFlagAddEarnSpeed.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
        } else if (eSkillType.DrugStoreBuildingEarnSkill.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.DrugStorePatronsStageLvLimitSkill.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.DrugStoreDrugTechSkill.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.TongBingTeamMaxSoldierAddi.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.ChuHanTeamMaxSoldierAddi.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }else if (eSkillType.SuiTangTeamMaxSoldierAddi.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }
        else if (eSkillType.WineryTradeWarAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }
        else if (eSkillType.WineryCalabashAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }
        else if (eSkillType.WineryHomeAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }
        else if (eSkillType.PatronsDispatchBuildingAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }
        else if (eSkillType.PatronsDispatchRankUnionWarAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }
        else if (eSkillType.TombAddPlayerAck.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }
        else if (eSkillType.TombAddPlayerHp.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }
        else if (eSkillType.XiaoXiongPatronHalo.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        }
        else if (eSkillType.GrandChildQualityWeightAddition.getValue() == skillInfo.getType()) {
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.CricketSkillMaxLevel.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(0);
            addition += (skillInfo.getUpgradeParamList().get(0) * (skillLv - 1));
        } else if (eSkillType.BeautyPeerlessSkillAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }else if (eSkillType.FiveHeroSkillAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        } else if (eSkillType.SonHaiPowerAddition.getValue() == skillInfo.getType()){
            addition = skillInfo.getParamList().get(1);
            addition += (skillInfo.getUpgradeParamList().get(1) * (skillLv - 1));
        }
        return addition;
    }

    /**
     * 门客、美女皮肤的技能升级特殊性获取
     * @param upgradeType
     * @param level
     * @return
     */
    public static SkillUpgradeInfo getSkillUpgradeInfoIfNotGetMax(int upgradeType, int level) {
        SkillUpgradeInfo skillUpgradeInfo = getSkillUpgradeInfo(upgradeType, level);
        if(null == skillUpgradeInfo){
            int maxLv = 0;
            Map<Integer, SkillUpgradeInfo> dataMap = skillUpgradeInfoMap.get(upgradeType);
            if(null != dataMap){
                for(SkillUpgradeInfo data : dataMap.values()){
                    if(data.getLevel() > maxLv && data.getLevel() <= level){
                        maxLv = data.getLevel();
                        skillUpgradeInfo = data;
                    }
                }
            }
        }
        return skillUpgradeInfo;
    }

    public static SkillInfo getSkillWith(int skillType, int  consumeItemId) {
        List<SkillInfo> list = skillInfoTypeListMap.get(skillType);
        if (list == null) {
            return null;
        }
        return list.stream().filter(v -> {
            if (v.getConsumeGoodsId().size() != 1) {
                return false;
            }
            return v.getConsumeGoodsId().get(0) == consumeItemId;
        }).findFirst().orElse(null);
    }

    /**
     * 获取当前等级升至满级所需要的消耗
     */
    public static long getTotalConsumeOfSkillUpgradeMaxLevel(int upgradeType, int curLv) {
        // 获取满级
        int maxLv = getSkillMaxLvByUpgradeType(upgradeType);
        long totalConsume = 0;
        while (curLv < maxLv) {
            SkillUpgradeInfo skillUpgradeInfo = getSkillUpgradeInfo(upgradeType, curLv);
            if (skillUpgradeInfo == null) {
                break;
            }
            totalConsume += skillUpgradeInfo.getConsumeCount();
            curLv++;
        }
        return totalConsume;
    }

    /**
     * 蛐蛐主动技能
     *
     * @param skillId 技能id
     */
    public static boolean isCricketActiveSkill(int skillId) {
        SkillInfo skillInfo = getSkillInfo(skillId);
        if (skillInfo == null) {
            return false;
        }
        return skillInfo.getType() == eSkillType.CricketBattleSkill137.getValue();
    }

    public static List<SkillInfo> getCricketNormalSkill() {
        return cricketNormalSkill;
    }
}
